from itertools import permutations, islice

class Solution:
    def getPermutation(self, n: int, k: int) -> str:
        return ''.join(map(str, next(islice(permutations(range(1, n+1)), k-1, None), None)))

if __name__ == "__main__":
    s = Solution()
    print(s.getPermutation(3, 3))
    print(s.getPermutation(4, 9))

